/**
 * Created with IntelliJ IEDA.
 * Description:
 * User:86186
 * Date:2023-04-12
 * Time:17:53
 */

/**
 * JZ15 二进制中1的个数
 */

public class NumberOf1 {
    public static void main(String[] args) {
        System.out.println(NumberOf1(10));
    }
    public static int NumberOf1(int n) {
        int count = 0;
        while (n != 0) {
            count += n & 1;
            n >>>= 1;
        }
        return count;
    }
}
